Using
an Event Callback to Manage Buffered Playback
To use an
event callback, use the CreateEventJ_ZBJV function to retrieve the handle of an event. In
a call to the midiOutOpen1UBKBTS
function, specify CALLBACK_EVENT for the dwFlags parameter. After using
the midiOutPrepareHeaderC2JN6Y
function but before sending MIDI events to the device, create a nonsignaled
event by calling the ResetEvent1.IH1GV function, specifying the event handle retrieved by CreateEvent.
Then, inside a loop that checks whether the MHDR_DONE bit is set in the dwFlags
member of the MIDIHDR8OW3.JO
structure, use the WaitForSingleObjectJ9IQ2G function, specifying the event handle and a
time-out value of INFINITE as parameters.
An event
callback is set by anything that might cause a function callback.
Because event
callbacks do not receive specific close, done, or open notifications, an application
may need to check the status of the process it is waiting for after the event
occurs. It is possible that a number of tasks could be completed by the time WaitForSingleObject
returns.